package healththink



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
//@TestFor(FacilityController)
class FacilityControllerTests extends grails.test.ControllerUnitTestCase {
	
	@Test
    void testFacilityController_SearchResults() {
		def instances = [
			new Facility(name:"test1", 
					longitude:10, 
					latitude:10,
					facilityType:FacilityType.Emergency),
			new Facility(name:"test2",
					longitude:10, 
					latitude:10,
					facilityType:FacilityType.Emergency)
		]
		
		mockDomain(Facility, instances)
		
		this.controller.params.facilitySearch = "test"
		
		def model = this.controller.searchResults()
		
		List<Facility> expected = model["facilities"]
		assertEquals "test2", expected[1]?.name
		assertEquals "test", model["term"]
    }
	
	@Test
    void testFacilityController_View() {
		def instances = [
			new Facility(name:"test1", 
					longitude:10, 
					latitude:10,
					facilityType:FacilityType.Emergency),
			new Facility(name:"test2",
					longitude:10, 
					latitude:10,
					facilityType:FacilityType.Emergency)
		]
		
		mockDomain(Facility, instances)
		
		this.controller.params.name = "test1"
		
		def model = this.controller.view()
		
		List<Forum> expected = model["forumList"]
		assertNull expected
		assertEquals "test1", model["facility"]?.name
    }

}
